author "jbergstroem"

start on runlevel [2345]
stop on runlevel [016]

# restart the job indefinitely with a 20 sec delay
respawn
respawn limit 0 20

# logging lives in /var/log/upstart/jenkins.log
console log

env HOME=/home/iojs
env NODE_COMMON_PIPE="$HOME/test.pipe"
env NODE_TEST_DIR="$HOME/tmp"
env JOBS="{{ jobs_env }}"
env OSTYPE=linux-gnu

# default path in ubuntu 1404 plus ccache
env PATH="/home/{{ server_user }}/nghttp2/src:/home/{{ server_user }}/wrk:/usr/lib/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

setgid iojs
setuid iojs

script

  if [ $(uname -i) = "ppc64le" ]; then
    export PATH=/home/iojs/jdk8u172-b11/bin:$PATH;
  fi

  exec java -Xmx{{ server_ram|default('128m') }} \
        -jar /home/{{ server_user }}/slave.jar -secret {{ secret }} \
        -jnlpUrl {{ jenkins_url }}/computer/{{ inventory_hostname }}/slave-agent.jnlp
end script
